package com.guxingke.typecho4j.widget.provider.option;

import com.guxingke.typecho4j.Typecho4jException;
import com.guxingke.typecho4j.widget.WidgetProvider;
import com.guxingke.typecho4j.widget.provider.OptionBaseWidget;
import com.jfinal.core.Controller;

/**
 * 默认编辑配置信息组件
 * 
 * @author guxingke
 *
 */
public class ThemeOptionWidget extends OptionBaseWidget implements
		WidgetProvider {
	private boolean showRecentPosts;
	private boolean showRecentComments;
	private boolean showCategory;
	private boolean showArchive;
	private boolean showOther;

	@Override
	public boolean init() {
		initLogger();
		InitParam();
		return true;
	}

	private void InitParam() {
		showRecentPosts = ("1".equals(getValue("ShowRecentPosts"))) ? true
				: false;
		showRecentComments = ("1"
				.equals(getValue("showRecentComments"))) ? true
				: false;
		showCategory = ("1".equals(getValue("showCategory"))) ? true
				: false;
		showArchive = ("1".equals(getValue("showArchive"))) ? true
				: false;
		showOther = ("1".equals(getValue("showOther"))) ? true : false;
	}

	@Override
	public void excute(Controller controller) throws Typecho4jException {
		controller.setAttr("themeOption", this);
	}

	@Override
	public void refresh() {
		InitParam();
	}

	public boolean isShowRecentPosts() {
		return showRecentPosts;
	}

	public boolean isShowRecentComments() {
		return showRecentComments;
	}

	public boolean isShowCategory() {
		return showCategory;
	}

	public boolean isShowArchive() {
		return showArchive;
	}

	public boolean isShowOther() {
		return showOther;
	}
}
